﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Excellent
{
    public partial class InformationlistForm : Form
    {
        public InformationlistForm()
        {
            InitializeComponent();
        }


        private void InformationlistForm_Load(object sender, EventArgs e)
        {

            string sql = string.Format(@"select * from T_gacct");
            DataSet ds = DBHelper.GetDataSet(sql);
            DataTable Dt = ds.Tables[0];
            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                TreeNode root = new TreeNode(Dt.Rows[i]["grade"].ToString());
                root.Tag = Dt.Rows[i]["gradeid"].ToString();
                tVinformation.Nodes.Add(root);
                string Sql = String.Format(@"select * from StudentUsers a,T_gacct b where  a.gradeid=b.gradeid and b.gradeid=" + root.Tag);
                DataSet Ds = DBHelper.GetDataSet(Sql);
                for (int a = 0; a < Ds.Tables[0].Rows.Count; a++)
                {
                    TreeNode toot1 = new TreeNode(Ds.Tables[0].Rows[a]["name"].ToString());              
                    root.Nodes.Add(toot1);

                }

            }
        }

        private void tVinformation_AfterSelect(object sender, TreeViewEventArgs e)
        {          
                textBox1.Text = tVinformation.SelectedNode.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string text = this.textBox1.Text;
            string Sql = string.Format(@"select * from StudentUsers a,T_gacct b where  a.gradeid=b.gradeid and name='{0}'", text);
            DataSet ds = DBHelper.GetDataSet(Sql);
            this.dgvInformation.AutoGenerateColumns = false;
            this.dgvInformation.DataSource = ds.Tables[0];
        }
    }
}
